const target = [
  '49.7301',
  '38.5900x003',
  '38.5901',
  '38.5902',
  '38.5903',
  '38.5900x005',
  '38.5900x008',
  '53',
  '85.21',
  '80.51',
  '79.31',
  '79.32',
  '79.12',
  '83.1900x019',
  '83.1900x020',
  '83.1903',
  '82.2101',
  '82.3101',
  '79.1900x005',
  '83.3902',
  '80.8602',
  '86.26',
  '55.0400x005',
  '55.0400x008',
  '55.0403',
  '56.0x06',
  '56.0x07',
  '56.0x08',
  '61.4901',
  '61.4905',
  '62.5',
  '63.1x01',
  '63.1x03',
  '59.4',
  '59.5',
  '59.6',
  '59.71',
  '59.79',
  '45.42',
  '48.36',
  '65.24',
  '65.25',
  '28.2',
  '54.3x00',
  '54.3x01',
  '54.3x00x027',
  '11.3200',
  '11.320111.3202',
  '11.3203',
  '12.7300',
  '12.7200',
  '13.71',
  '13.41',
  '18.21',
  '19.4x01',
  '19.4x00x005',
  '30.0903',
  '30.0904',
  '30.2100x002',
  '30.0906',
  '30.0900x039',
  '08.32',
  '12.64',
  '12.1403',
  '15.6x00',
  '15.1',
  '15.2',
  '15.3',
  '15.4',
  '15.5',
  '15.9',
  '14.7903',
  '14.5903',
  '14.3901',
  '14.2900x002',
  '08.5900x004',
  '08.5900x005',
  '08.5902',
  '08.41-08.49',
  '09.7300x004+09.7301+09.4404',
  '09.4200+09.4404',
  '09.7201+09.4404',
  '09.7301+09.4404',
  '08.2000x006',
  '20.0100',
  '20.0100x006',
  '19.4',
  '18.2900x003',
  '21.3104',
  '21.3102',
  '21.5x00',
  '21.8400x002',
  '21.5x00x004',
  '21.5x01',
  '21.3200x003',
  '28.6',
  '29.3901',
  '30.0911',
  '30.0900x008',
  '29.3908',
  '27.4906',
  '29.3901',
  '21.0300x004',
  '21.8500x004',
  '49.1100',
  '48.8101',
  '49.0100x004',
  '49.46',
  '49.4900x003',
  '49.4901',
  '53.0100x001',
  '53.0202',
  '53.0204',
  '53.4901',
  '85.2100',
  '85.2200',
  '85.2401',
  '59.8x03',
  '59.8x00x001',
  '97.6204',
  '97.6205',
  '58.3901',
  '55.0105',
  '58.6x00',
  '61.2x00',
  '62.9900x001',
  '61.3x03',
  '63.1x01',
  '58.3906',
  '63.3x03',
  '64.2x01',
  '63.8300',
  '60.1901',
  '57.0',
  '62.1100',
  '62.1200',
  '60.1101',
  '60.1100x003',
  '55.9601',
  '67.2x00',
  '67.3202',
  '80.511',
  '80.5100x032',
  '80.5100x033',
  '78.6',
  '77.4',
  '86.3x05',
  '86.3x01',
  '88.5700',
];
const result = [];
let dbConfigSource = {
  server: '10.160.12.192',
  database: 'MR_FS_DB',
  user: 'sa',
  password: 'Docimax@123',
  port: 1433,
};
let db = require('./db');
let fs = require('fs');
let sqlserver = require('mssql');
let sql = 'select ICDCode from [Map_Operate] where targetICDCode like ';
let con = undefined;
async function getConnection() {
  if (con == undefined) {
    con = await sqlserver.connect(dbConfigSource);
  }
  return con;
}
async function getBJICDCode() {
  pool = await getConnection();
  for (let index = 0; index < target.length; index++) {
    const element = target[index];
    let csql = sql + "'" + element + "%'";
    let r = await pool.request().query(csql);
    let rs = r.recordset;
    for (let index = 0; index < rs.length; index++) {
      const res = rs[index];
      result.push(res['ICDCode']);
    }
  }
  await pool.close();
  console.log(result);
  fs.writeFileSync('d:\\icdresult.json', JSON.stringify(result));
}
getBJICDCode();
